
package org.apache.mina.common;

/**
 * A configuration which is used to configure {@link IoService}.
 * 
 * IoService的配置类。
 */
public interface IoServiceConfig extends Cloneable {
    /**
     * Resturns the default configuration of the new {@link IoSession}s.
     * 
     * 返回新IoSession的默认配置。
     */
    IoSessionConfig getSessionConfig();

    /**
     * Returns the {@link IoFilterChainBuilder} which will modify the
     * {@link IoFilterChain} of all {@link IoSession}s which is created with
     * this configuration. The default value is an empty
     * {@link DefaultIoFilterChainBuilder}.
     * 
     * 返回IoFilterChainBuilder，此构建器能修改IoFilterChain中根据配置文件创建的IoSession。
     * 默认值是一个空的DefaultIoFilterChainBuilder。
     */
    IoFilterChainBuilder getFilterChainBuilder();

    /**
     * Sets the {@link IoFilterChainBuilder} which will modify the
     * {@link IoFilterChain} of all {@link IoSession}s which is created with
     * this configuration. If you specify <tt>null</tt> this property will be
     * set to an empty {@link DefaultIoFilterChainBuilder}.
     * 
     * 看上面方法。
     */
    void setFilterChainBuilder(IoFilterChainBuilder builder);

    /**
     * A shortcut for <tt>( ( DefaultIoFilterChainBuilder ) </tt>
     * {@link #getFilterChainBuilder()}<tt> )</tt>. Please note that the
     * returned object is not a <b>real</b> {@link IoFilterChain} but a
     * {@link DefaultIoFilterChainBuilder}. Modifying the returned builder won't
     * affect the existing {@link IoSession}s at all, because
     * {@link IoFilterChainBuilder}s affect only newly created {@link IoSession}
     * s.
     * 
     * getFilterChainBuilder()方法的快捷方式。请注意：
     * 返回的对象不是真正的IoFilterChain而是DefaultIoFilterChainBuilder
     * 。修改此构建器，不会影响已存在的IoSession，因为IoFilterChainBuilder只会影响新创建的IoSession。
     * 
     * @throws IllegalStateException
     *             if the current {@link IoFilterChainBuilder} is not a
     *             {@link DefaultIoFilterChainBuilder}
     */
    DefaultIoFilterChainBuilder getFilterChain();

    /**
     * Returns the default {@link ThreadModel} of the {@link IoService}. The
     * default value is a {@link ExecutorThreadModel}() whose service name is <tt>'AnonymousIoService'</tt>
     * and which has 16 maximum active threads. It is strongly recommended to
     * set a new {@link ExecutorThreadModel} by calling
     * {@link ExecutorThreadModel#getInstance(String)}.
     * 
     * 返回IoService默认的ThreadModel。默认的值是ExecutorThreadModel，它的服务名是
     * 'AnonymousIoService'，最多拥有16个活动的线程。
     * 强烈推荐通过ExecutorThreadModel.getInstance(String)方法设置新的ExecutorThreadModel
     */
    ThreadModel getThreadModel();

    /**
     * Sets the default {@link ThreadModel} of the {@link IoService}. If you
     * specify <tt>null</tt>, this property will be set to the default value.
     * The default value is an {@link ExecutorThreadModel} whose service name is
     * <tt>'AnonymousIoService'</tt> with 16 threads. It is strongly recommended to set a new
     * {@link ExecutorThreadModel} by calling
     * {@link ExecutorThreadModel#getInstance(String)}.
     * 
     * 见上面
     */
    void setThreadModel(ThreadModel threadModel);

    /**
     * Returns a deep clone of this configuration.
     * 
     * 深克隆。
     */
    Object clone();
}
